package com.youngjun.common.pojo.dto.support;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;

/**
 * @author YoungJun
 */
public class PageDTO<DTO> {

    private Integer current;

    private Integer pageSize;

    private String orderBy;

    public Integer getCurrent() {
        return current;
    }

    public PageDTO<DTO> setCurrent(Integer current) {
        this.current = current;
        return this;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public PageDTO<DTO> setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public PageDTO<DTO> setOrderBy(String orderBy) {
        this.orderBy = orderBy;
        return this;
    }

    /**
     * DO to VO
     *
     * @return
     */
    @JsonIgnore
    public Mapper getDTOMapper() {
        return DozerBeanMapperBuilder.create().build();
    }

    public DTO mapFrom(Object src, Mapper mapper) {
        if (src != null){
            mapper.map(src, this);
        }
        return (DTO) this;
    }

    public DTO mapFrom(Object src) {
        return mapFrom(src, getDTOMapper());
    }

}